package com.kim.smartring.db.dao;

import java.util.List;

import android.content.Context;

import com.kim.smartring.db.model.StepRecord;
import com.kim.smartring.utils.DateUtils;

public class StepRecordDao extends BaseDao<StepRecord, String> {

	public StepRecordDao(Context context) {
		super(context);
	}

	/**
	 * 获取未同步及当天时间之前的日期
	 * 
	 * @return
	 */
	public List<StepRecord> getUnSyncStepRecords() {
		String strWhere = " sTimeEnd < " + DateUtils.getCurrentDayStartTime()
				+ " and sSyncState=0";
		return findAllByWhere(StepRecord.class, strWhere);
	}

	public void updateSyncState(List<StepRecord> stepRecords) {
		if (stepRecords == null || stepRecords.size() == 0) {
			return;
		}
		for (StepRecord record : stepRecords) {
			record.setsSyncState(1);
			update(record);
		}
	}
}
